#include "protocol_example.hpp"

namespace protocol
{
	const std::string ProtocolExampleReq::to_string() const
	{
		std::ostringstream oss;

		oss << Protocol::to_string() << " body: {name: " << _name << "}";

		/*
		oss << _seq_num << " " << (int)_cmd1 << " "
			<< _magic   << " " << _length << " "
			<< (int)_cmd0    << " " << (int)_cmd1   << " "
			<< _seq_num << " " << (int)_int8 << " "
			<< (int)_uint8 << " " << (int)_int16 << " "
			<< (int)_uint16 << " " << _int32 << " "
			<< _uint32 << " " << _int64 << " "
			<< _uint64 << " " << _string.size()
			<< " " << _string;
			// << " " << _string.substr(0, 10) << _string.substr(_string.size() - 10);
			*/

#if 0
		oss << "{head: " << Protocol::to_string()
			<< ", int8: " << (int)_int8
			<< ", uint8: " << (int)_uint8
			<< ", int16: " << (int)_int16
			<< ", uint16: " << (int)_uint16
			<< ", int32: " << _int32
			<< ", uint32: " << _uint32
			<< ", int64: " << _int64
			<< ", uint64: " << _uint64
			<< ", string: " << _string;
#endif

		return oss.str();
	}

	void ProtocolExampleReq::serialize(Streamer & streamer)
	{
		_length  = size();

		Protocol::serialize(streamer);

		streamer & _name;
		/*
		streamer & _int8
		         & _uint8
				 & _int16
				 & _uint16
				 & _int32
				 & _uint32
				 & _int64
				 & _uint64
				 & _string;
				 */

	}
	
	const std::string ProtocolExampleResp::to_string() const
	{
		std::ostringstream oss;

		oss << "{head: " << Protocol::to_string()
			<< ", int8: " << (int)_int8
			<< ", uint8: " << (int)_uint8
			<< ", int16: " << (int)_int16
			<< ", uint16: " << (int)_uint16
			<< ", int32: " << _int32
			<< ", uint32: " << _uint32
			<< ", int64: " << _int64
			<< ", uint64: " << _uint64
			<< ", string: " << _string;

		return oss.str();
	}

	void ProtocolExampleResp::serialize(Streamer & streamer)
	{
		Protocol::serialize(streamer);

		streamer & _int8
		         & _uint8
				 & _int16
				 & _uint16
				 & _int32
				 & _uint32
				 & _int64
				 & _uint64
				 & _string;
	}
};

